﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FineUI;


namespace mydddd.admin
{
    public partial class edit : BasePage
    {
        mydddd.BLL.sysAdmin bll = new mydddd.BLL.sysAdmin();
        mydddd.Model.sysAdmin mo = new mydddd.Model.sysAdmin();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    if (Session["admin"] == null)
                    {
                        return;
                    }
                    DataRow dr = Session["Admin"] as DataRow;
                    int adminid = int.Parse(dr["id"].ToString());
                    mo = bll.GetModel(adminid);
                    LoginName1.Text = mo.LoginName;
                    Hd_pwd.Text = mo.Password;
                  
                    realname.Text = mo.RealName;
                }
                catch (Exception)
                {
                    Response.End();
                }
            }
        }

        protected void Button_save_OnClick(object sender, EventArgs e)
        {
            if (Session["admin"] == null)
            {
                return;
            }
            DataRow dr = Session["Admin"] as DataRow;
            var id = int.Parse(dr["id"].ToString());
            var m = bll.GetModel(id);
            m.LoginName = LoginName1.Text;
            m.RealName = realname.Text;
       
            if (!string.IsNullOrEmpty(Password.Text))
                m.Password = Password.Text;
            if (bll.Update(m))
            {
                AlertInfor("修改成功", true);
            }
            else
            {
                Alert.Show("修改失败");
            }
        }


    }
}